home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat3 / stat.3 < prev    next >
Encoding:
Text File  |  1993-03-03  |  4.7 KB  |  133 lines

  1.  
  2.  
  3.  
  4. STAT(3)             MINTLIB LIBRARY FUNCTIONS             STAT(3)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        stat, lstat, fstat - get file status
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        #include <sys/types.h>
  12.        #include <sys/stat.h>
  13.  
  14.        int stat(const char *path, struct stat *buf);
  15.  
  16.        int lstat(const char *path, struct stat *buf);
  17.  
  18.        int fstat(int fd, struct stat *buf);
  19.  
  20. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  21.        stat  obtains  information  about  the file named by path.
  22.        Read, write or execute permission of the named file is not
  23.        required,  but  all  directories  listed  in the path name
  24.        leading to the file must be searchable.
  25.  
  26.        lstat is like stat except in the  cases  where  the  named
  27.        file  is  a  symbolic  link,  in  which case lstat returns
  28.        information about the link, while stat returns information
  29.        about the file the link references.
  30.  
  31.        fstat obtains the same information about an open file ref-
  32.        erenced by the the  file  descriptor,  such  as  would  be
  33.        returned by an creat, open, dup, fcntl or pipe call.
  34.  
  35.        buf  is  a pointer to a stat structure into which informa-
  36.        tion is placed concerning the file. The stat structure  is
  37.        defined  in <sys/stat.h> and contains the following fields
  38.        of interest:
  39.          struct stat
  40.          {
  41.            u_short      st_mode;         /*       file       mode
  42.        */
  43.            ino_t     st_ino;       /*   the  file  serial  number
  44.        */
  45.            dev_t    st_dev;      /*  device   file   resides   on
  46.        */
  47.            short     st_rdev;      /*   the   device   identifier
  48.        */
  49.            short   st_nlink;   /* number of  hard  links  to  the
  50.        file   */
  51.            uid_t     st_uid;       /*   user   ID  of  the  owner
  52.        */
  53.            gid_t    st_gid;      /*  group  ID   of   the   owner
  54.        */
  55.            off_t    st_size;     /*  total  size  of the file, in
  56.        bytes   */
  57.            off_t   st_blksize; /* preferred blocksize for  system
  58.        I/O */
  59.            off_t    st_blocks;   /* actual number of blocks allo-
  60.        cated  */
  61.  
  62.  
  63.  
  64. MiNT docs 0.1              3 March 1993                         1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. STAT(3)             MINTLIB LIBRARY FUNCTIONS             STAT(3)
  71.  
  72.  
  73.            time_t   st_mtime;    /*   file   last   modify   time
  74.        */
  75.            time_t    st_atime;     /*   file   last  access  time
  76.        */
  77.            time_t  st_ctime;   /* file last  status  change  time
  78.        */
  79.            short       st_attr;        /*     file     attributes
  80.        */
  81.            ...                 /*  various  fields  reserved  for
  82.        MiNT   */
  83.          };
  84.  
  85.        The  following masks are available in <sys/stat.h> to test
  86.        the st_mode field in the stat structure:
  87.          #define S_IFMT    0170000   /* type of file         */
  88.          #define S_IFCHR   0020000   /* character special    */
  89.          #define S_IFDIR   0040000   /* directory            */
  90.          #define S_IFBLK   0060000   /* block special        */
  91.          #define S_IFREG   0100000   /* regular file         */
  92.          #define S_IFIFO   0120000   /* FIFO special         */
  93.          #define S_IMEM    0140000   /* shared memory (?)    */
  94.          #define S_IFLNK   0160000   /* symbolic link        */
  95.          #define S_ISUID   04000     /* set-uid on execution */
  96.          #define S_ISGID   02000     /* set-gid on execution */
  97.          #define S_ISVTX   01000     /* save swapped text    */
  98.  
  99.        The following masks are available in <sys/stat.h> to  test
  100.        the st_attr field in the stat structure:
  101.          #define S_IRUSR   0400      /* readable by user     */
  102.          #define S_IWUSR   0200      /* writeable by user    */
  103.          #define S_IXUSR   0100      /* executable by user   */
  104.          #define S_IRGRP   0040      /* readable by group    */
  105.          #define S_IWGRP   0020      /* writable by group    */
  106.          #define S_IXGRP   0010      /* executable by group  */
  107.          #define S_IROTH   0004      /* readable by others   */
  108.          #define S_IWOTH   0002      /* writable by others   */
  109.          #define S_IXOTH   0001      /* executable by others */
  110.  
  111. R✓RE✓ET✓TU✓UR✓RN✓N V✓VA✓AL✓LU✓UE✓ES✓S
  112.         0   on success.  -1  on failure; errno is set to indicate
  113.        the error.
  114.  
  115. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  116.        c✓ch✓hm✓mo✓od✓d(✓(3✓3)✓),✓, c✓ch✓ho✓ow✓wn✓n(✓(3✓3)✓),✓, F✓Fc✓cn✓nt✓tl✓l(✓(2✓2)✓),✓, F✓Fx✓xa✓at✓tt✓tr✓r(✓(2✓2)✓)
  117.  
  118. N✓NO✓OT✓TE✓E
  119.        When MiNT is not active, these calls  are  emulated  under
  120.        TOS.   The  TOS  implemenation  of  fstat in particular is
  121.        pretty bogus.  You are advised to read the source code  of
  122.        stat.c  if  you  want  to  make use of other than the most
  123.        basic attributes under TOS emulation.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. MiNT docs 0.1              3 March 1993                         2
  131.  
  132.  
  133.